package com.ce.pms.common.model;

import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Embeddable;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

import org.springframework.context.ApplicationContext;
import org.springframework.context.support.FileSystemXmlApplicationContext;
import org.springframework.web.context.support.StaticWebApplicationContext;

import com.ce.pms.common.dao.ISysrefcodeDao;
import com.ce.pms.customer.dao.IHisResidentDao;
import com.ce.util.DateUtil;
/**
 * 系统信息值对象,嵌入各DO中表示该DO的创建时间，创建人，修改时间，修改人等信息
 * @author Adama Yue
 */
@Embeddable
public class SysInfo {

	/**
	 * 英文半角逗号分隔符 如：<b> , <b>
	 */
	public static final String SEPARATOR_COMMA = SysrefcodeDO.CONSTANTS_COMMA;

	/**
	 * 有效值常量："1"
	 */
	public static final String VALIDITY = SysrefcodeDO.CONSTANTS_DIGITAL_ONE;   //有效

	/**
	 * 无效值常量："0"
	 */
	public static final String  INVALIDATION = SysrefcodeDO.CONSTANTS_DIGITAL_ZERO;   //无效

	/**
	 * 创建者ID
	 */
	@Column(name="CREATOR",nullable=false,insertable=true,updatable=false)
	private Long creator;
	
	/**
	 * 创建日期
	 */
	@Temporal(TemporalType.TIMESTAMP)
	@Column(name="SYSDATE",nullable=false,insertable=true,updatable=false)
	private Date sysDate;
	
	/**
	 * 修改者ID
	 */
	@Column(name="MODIFIER",nullable=true,insertable=false,updatable=true)
	private Long modifier;
	
	/**
	 * 修改日期
	 */
	@Temporal(TemporalType.TIMESTAMP)
	@Column(name="MODIFY_DATE",nullable=true,insertable=false,updatable=true)
	private Date modifyDate;

	/*********************************************
	 * bussines code
	 *********************************************/
//	public static SysInfo createBy(Long creator) {
//
//		return new SysInfo(creator,DateUtil.getCurrentDate());
//
////		String[] classPath = new String[] {"resource/modules/spring.xml","resource/modules/**/spring-conf/*.xml"};
////		ApplicationContext context = new FileSystemXmlApplicationContext(classPath);
////
//////		StaticWebApplicationContext
////		IHisResidentDao dao = (IHisResidentDao) context.getBean("hisResidentDao");
////		SysInfo info = new SysInfo();
////		info.setCreator(creator);
////		info.setSysDate(dao.getDate());
////
////		return info;
//	}
//	public void modifyBy(Long modifier) {
////		String[] classPath = new String[] {"resource/modules/spring.xml","resource/modules/**/spring-conf/*.xml"};
////		ApplicationContext context = new FileSystemXmlApplicationContext(classPath);
////		IHisResidentDao dao = (IHisResidentDao) context.getBean("hisResidentDao");
////
////
////		this.setModifier(modifier);
//		this.setModifyDate(DateUtil.getCurrentDate());
////		this.setModifyDate(dao.getDate());
//	}
	//构造器
	public SysInfo() {
		super();
	}
	/**
	 * 最小化构造器
	 * @param creator 创建人
	 * @param sysDate 创建日期
	 */
	public SysInfo(Long creator, Date sysDate) {
		super();
		this.creator = creator;
		this.sysDate = sysDate;
	}
	public Long getCreator() {
		return creator;
	}
	public void setCreator(Long creator) {
		this.creator = creator;
	}
	public Long getModifier() {
		return modifier;
	}
	public void setModifier(Long modifier) {
		this.modifier = modifier;
	}
	public Date getModifyDate() {
		return modifyDate;
	}
	public void setModifyDate(Date modifyDate) {
		this.modifyDate = modifyDate;
	}
	public Date getSysDate() {
		return sysDate;
	}
	public void setSysDate(Date sysDate) {
		this.sysDate = sysDate;
	}




}
